import { useUserStoreWithOut } from "@/store/modules/user"
const imgEmpty = 'https://hb-saas.obs.cn-south-1.myhuaweicloud.com/mall/saas/icon/emptyIcon/img-empty.png';

// 获取活动海报配置数据
export function getAlbumPosterData(data: { name: string, coverUrl: string, describe: string }, codeImg: string): PainterBoard[] {
  const { userInfo } = useUserStoreWithOut()

  const coverUrl = data.coverUrl || imgEmpty

  return [
    {
      css: {
        width: '800rpx',
      },
      views: [
        {
          type: 'view',
          css: {
            background: '#F2F3F5',
            padding: '40rpx'
          },
          views: [
            {
              type: 'view',
              css: {
                marginBottom: '32rpx'
              },
              views: [
                {
                  type: 'image',
                  src: userInfo.avatar,
                  css: {
                    width: '96rpx',
                    height: '96rpx',
                    borderRadius: '50%',
                    background: '#fff',
                    objectFit: 'cover'
                  }
                },
                {
                  type: 'text',
                  text: `Hi 我是${userInfo.userName} \n${data.describe}`,
                  css: {
                    color: '#333',
                    fontSize: '28rpx',
                    lineHeight: '44rpx',
                    marginLeft: '16rpx'
                  }
                },
              ]
            },
            {
              type: 'image',
              src: coverUrl,
              css: {
                width: '100%',
                height: '576rpx',
                borderRadius: '16rpx',
                objectFit: 'cover'
              }
            }
          ]
        },
        {
          type: 'view',
          css: {
            padding: '40rpx',
            background: '#fff',
            position: 'relative',
          },
          views: [
            {
              type: 'view',
              css: {
                width: '520rpx',
                color: '#333',
              },
              views: [
                {
                  text: data.name,
                  type: 'text',
                  css: {
                    fontSize: '40rpx',
                    lineClamp: 1,
                    marginBottom: '8px'
                  }
                },
                {
                  type: 'view',
                  views: [
                    {
                      type: 'text',
                      text: '微信扫码立即查看 >>>',
                      css: {
                        fontSize: '24rpx',
                        color: '#999996',
                      }
                    }
                  ]
                },
              ]
            },
            {
              type: 'view',
              css: {
                position: 'absolute',
                right: '40rpx',
                top: '25rpx',
              },
              views: [
                {
                  type: 'image',
                  src: codeImg,
                  css: {
                    width: '160rpx',
                    height: '160rpx',
                  }
                },
              ]
            },
            {
              type: 'view',
              css: {
                width: '100%',
                height: '40rpx',
                background: '#fff'
              }
            }
          ]
        },

      ]
    }
  ]
}